package com.originalpoint.origin_server.controller;


import com.originalpoint.origin_server.pojo.Merchat;
import com.originalpoint.origin_server.empty.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;;
import java.util.List;
import com.originalpoint.origin_server.service.MerchatService;
/**
 *@作者:lhj
 *Controller接口
 *@Date:2023/07/02
 */
@CrossOrigin
@RestController
@RequestMapping("/MerchatURL")
public class MerchatController {


    @Autowired
    private MerchatService merchatservice;


    /**
     根据MerId查询
     */
    @ApiOperation(value  = "根据MerId查询商家表")
    @GetMapping("/selectByMerId/{merId}")
    public Result selectByMerId(@PathVariable(value = "merId") Integer merId){
        return Result.buildSuccess(merchatservice.selectByMerId(merId));
    }


    /**
     根据MerId更新
     */
    @ApiOperation(value  = "根据MerId更新商家表")
    @PostMapping("/updateByMerId")
    public Result updateByMerId(@RequestBody Merchat demo){
        return Result.buildSuccess(merchatservice.updateByMerId( demo));
    }



    /**
     根据MerId删除
     */
    @ApiOperation(value  = "根据MerId删除商家表信息")
    @GetMapping("/deleteByMerId/{merId}")
    public Result deleteByMerId(@PathVariable(value = "merId") Integer merId){
        return Result.buildSuccess(merchatservice.deleteByMerId(merId));
    }





    /**
     insert:(插入)
     */
    @ApiOperation(value  = "插入商家表信息")
    @PostMapping("/insert")
    public Result insert(@RequestBody Merchat demo){
        Result.buildSuccess(merchatservice.insert(demo));
        return Result.buildSuccess(demo);
    }



    /**
     insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
     */
    @ApiOperation(value  = "插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变)商家表信息")
    @PostMapping("/insertOrUpdate")
    public Result insertOrUpdate(@RequestBody Merchat demo){
        return Result.buildSuccess(merchatservice.insertOrUpdate(demo));
    }



    /**
     insertBath:(批量插入)
     */
    @ApiOperation(value  = "批量插入商家表信息")
    @PostMapping("/insertBatch")
    public Result insertBatch(@RequestBody List<Merchat> list){
        return Result.buildSuccess(merchatservice.insertBatch(list));
    }



    /**
     insertOrUpdateBatch:(批量插入或更新)
     */
    @ApiOperation(value  = "批量插入或更新商家表信息")
    @PostMapping("/insertOrUpdateBatch")
    public Result insertOrUpdateBatch(@RequestBody List<Merchat> list){
        return Result.buildSuccess(merchatservice.insertOrUpdateBatch(list));
    }



    /**
     selectList:(根据参数查询集合)
     */
    @ApiOperation(value  = "根据参数查询集合")
    @PostMapping("/selectList")
    public Result selectList(@RequestBody Map<String,Object> param){
        return Result.buildSuccess(merchatservice.selectList(param),merchatservice.selectCount(param));
    }



    /**
     selectCount:(根据集合查询数量)
     */
    @ApiOperation(value  = "根据集合查询数量")
    @PostMapping("/selectCount")
    public Result selectCount(@RequestBody Map<String,Object> param){
        return Result.buildSuccess(merchatservice.selectCount(param));
    }



}